<?php

namespace App\Common;

use Illuminate\Support\Facades\Validator;

class ValidatorCheck{

    /**
     * 验证过滤
     * @param $params
     * @param $rules
     * @name czy
     */
    public static function paramsCheck($params,$rules){

        $validator = Validator::make($params,$rules);
        if ($validator->fails()){
            $errorMsg = $validator->messages();
            if(!is_array($errorMsg)) $errorMsg =$errorMsg->toArray();
            $errorArr=[];
            foreach ($errorMsg as $key=>$val) $errorArr[]= $key.":".$val[0];
            exit(Responses::errorValidate($errorArr));
        }
        return true;
    }


}
